﻿using UnityEngine;
using System.Collections;
//temp
public class DikeMover : MonoBehaviour
{
    [SerializeField]
    private float max = 5;
    [SerializeField]
    private float scoreY = 13;
    public  GameController_ScoreManager scoreManager;
    private bool valid;
    void Awake() 
    {
        valid = true;
    }

    public void SetVelosity(float val) 
    {
        rigidbody2D.velocity = new Vector2(0, val);
    }

	void Update () 
    {
        if (transform.position.y > scoreY && valid) 
        {
            valid = false;
            scoreManager.AddScore();
            audio.PlayOneShot(audio.clip);
        }
        else if (transform.position.y > max - 5) 
        {
            Destroy(gameObject);
        }
	}
}
